/*
 __   _____  _     ___     _   _ _   _ ___ _____ 
 \ \ / / _ \| |   / _ \   | \ | | \ | |_ _| ____|
  \ V / | | | |  | | | |  |  \| |  \| || ||  _|  
   | || |_| | |__| |_| |  | |\  | |\  || || |___ 
   |_| \___/|_____\___/___|_| \_|_| \_|___|_____|
                     |_____|                     
  (C)2024 YOLO NNIE

 * Description:
        YOLO nnie detection : Yolo nnie project trace helpers

 * License: halokitor @ xidian university
 *
 * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef FFMPEG_RTMP_H
#define FFMPEG_RTMP_H

#include "hi_type.h"
#include "hi_comm_svp.h"

#include "libavcodec/avcodec.h"
#include "libavutil/avstring.h"
#include "libavutil/mathematics.h"
#include "libavutil/pixdesc.h"
#include "libavutil/imgutils.h"
#include "libavutil/dict.h"
#include "libavutil/parseutils.h"
#include "libavutil/samplefmt.h"
#include "libavutil/avassert.h"
#include "libavutil/time.h"
#include "libavformat/avformat.h"
#include "libswscale/swscale.h"
#include "libavutil/opt.h"
#include "libavcodec/avfft.h"
#include "libswresample/swresample.h"
#include "libavutil/avutil.h"

#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* __cplusplus */

typedef enum s_tFrameType
{
    MEDIA_TYPE_VIDEO = 0x00,
    MEDIA_TYPE_AUDIO,
};

typedef struct s_tH264SPSPPSHeader
{
    unsigned char *sps_pps_buf;
    HI_U32 sps_pps_size;
    HI_BOOL has_sps_pps;
    HI_BOOL isStreamInit;
    HI_BOOL isKeyFrame;
    HI_BOOL isFirstIdrFrame;
    HI_U64 start_pts;
} tH264SPSPPSHeader;

/* -------------------------------------------------------------------------- */
/* --- PUBLIC FUNCTION ------------------------------------------------------ */
HI_S32 initFFmpegNetwork( HI_VOID );

HI_VOID cleanFFmpegSetting( HI_VOID );

HI_VOID init_h264_sps_pps_header( int size );

HI_VOID freeH264SpsPpsHeader( HI_VOID );

HI_S32 hisi_tx_rtmp_video(const uint8_t *frame, int size, uint64_t ts);

HI_S32 hisi_tx_rtmp_audio(const uint8_t *frame, int size, uint64_t ts);

#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */

#endif /* SAMPLE_SVP_MAIN_H */
